import { defineStore } from 'pinia'
import { store } from '../index'
import { useStorage } from '@/hooks/web/useStorage'

const { getStorage, setStorage } = useStorage('localStorage')
interface DraftItem {
  time: number
  data: object
}
interface DraftState {
  list: { [key: string]: DraftItem[] }
}
export const useDraftStore = defineStore('draft', {
  state: (): DraftState => {
    return {
      list: {}
    }
  },
  getters: {
    // getCurrentLocale(): LocaleDropdownType {
    //   return this.currentLocale
    // },
  },
  actions: {
    // 查询
    query() {},
    // 新增
    create() {},
    // 编辑
    modify() {},
    // 删除
    del() {}
    // setCurrentLocale(localeMap: LocaleDropdownType) {
    //   // this.locale = Object.assign(this.locale, localeMap)
    //   this.currentLocale.lang = localeMap?.lang
    //   this.currentLocale.elLocale = elLocaleMap[localeMap?.lang]
    //   setStorage('lang', localeMap?.lang)
    // }
  }
})

export const useDraftStoreWithOut = () => {
  return useDraftStore(store)
}
